package cw.spring.security.acl.poc.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Used to store the last run of stardust feeding tools (MACAO, Markit...)
 * 
 * @author montagnoncy
 * 
 */
@Entity
@Table(name = "Acl_Entry")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AclEntryModel {

  private AclObjectIdentityModel aclObjectIdentity;
  private Integer mask;
  private Integer aceOrder;
  private Boolean granting;
  private Boolean auditSuccess;
  private Boolean auditFailure;
  private AclSidModel sid; // name of the user

  @ManyToOne
  @JoinColumn(name = "sid", nullable = false)
  public AclSidModel getSid() {
    return sid;
  }

  public void setSid(AclSidModel sid) {
    this.sid = sid;
  }

  private long id;

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }

  @ManyToOne
  @Cascade( { CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN })
  @JoinColumn(name = "acl_object_identity", nullable = false)
  public AclObjectIdentityModel getAclObjectIdentity() {
    return aclObjectIdentity;
  }

  public void setAclObjectIdentity(AclObjectIdentityModel aclObjectIdentity) {
    this.aclObjectIdentity = aclObjectIdentity;
  }

  public Integer getMask() {
    return mask;
  }

  public void setMask(Integer mask) {
    this.mask = mask;
  }

  @Column(name = "ace_order")
  public Integer getAceOrder() {
    return aceOrder;
  }

  public void setAceOrder(Integer aceOrder) {
    this.aceOrder = aceOrder;
  }

  public Boolean getGranting() {
    return granting;
  }

  public void setGranting(Boolean granting) {
    this.granting = granting;
  }

  @Column(name = "audit_success")
  public Boolean getAuditSuccess() {
    return auditSuccess;
  }

  public void setAuditSuccess(Boolean auditSuccess) {
    this.auditSuccess = auditSuccess;
  }

  @Column(name = "audit_failure")
  public Boolean getAuditFailure() {
    return auditFailure;
  }

  public void setAuditFailure(Boolean auditFailure) {
    this.auditFailure = auditFailure;
  }
}
